#define _CRT_SECURE_NO_WARNINGS 1
#include<stdio.h>
void Swap(int* a, int* b)
{
	int tmp = *a;
	*a = *b;
	*b = tmp;
}
void bubblesort(int* a, int size) {

	for (int i = 0; i < size-1; i++) 
	{
		int flag = 0;
		for (int j = 0; j < size - i - 1; j++) {
			if (a[j] > a[j + 1]) 
			{
				Swap(&a[j], &a[j + 1]);
				flag = 1;   
			}
		}
		if (flag == 0) {   
			break;
		}
	}
}

int main()
{
	int arr[9] = { 2,4,1,3,8,7,9,6,5 };
	bubblesort(arr, 9);
	for (int i = 0; i < 9; i++)
	{
		printf("%d ", arr[i]);
	}
	return 0;
}